1. Field of the Invention
The present invention relates generally to increasing utilization and overall performance in multi-threading microprocessors. More particularly, the present invention relates to reducing idle time in simultaneous multi-threading processors with minimal circuit impact and minimal machine cost.
2. Related Art
In a conventional computer system, microprocessors run several processes. The computer system utilizes an operating system (OS) to direct the microprocessor to run each of the processes based on priority and on the process not waiting on an event (e.g., a disk access or a user keypress) to continue. A simple type of priority system simply directs the OS to run the programs in sequence (i.e., the last program to be run has the lowest priority). In other systems, the priority of a program may be assigned based on other factors, such as the importance of the program, how efficient it is to run the program, or both. Through priority, the OS is then able to determine the order in which programs or software threads or contexts are executed by the processor. It takes a significant amount of time, typically more than several hundred instructions, for the OS to switch from one running process to another running process.
Because of the process switching overhead, the OS will only switch out a process when it knows the process will not be running again for a significant amount of time. However, with the increasing speed of processors, there are events, which make the process unexecutable for a certain amount of time not long enough to justify an OS-level process switch. When the program is stalled by such an event, such as a cache miss (e.g., when a long latency memory access is required), the processor experiences idle cycles for the duration of the stalling event, decreasing the overall system performance. Because newer and faster processors are always being developed, the number of idle cycles experienced by processors is also increasing. Although memory access speed is also being improved, it does not improve at the same rate as microprocessor speeds, therefore, processors are spending an increasing percentage of time waiting for memory to respond.
Recent developments in processor design have allowed for multi-threading, where two or more distinct threads are able to make use of available processor resources. Two particular forms of multi-threading are Switch on Event Multi-Threading (SoEMT) and Simultaneous Multi-Threading (SMT), each of which have advantages and disadvantages by comparison. In SoEMT, if a first thread is stalled by an event, the processor (not the OS) may switch the execution context to a second thread to avoid idle cycles. In SMT, two threads are able to run in parallel, a feature that is particularly useful in wide processors, which have the bandwidth to execute additional operations at the same time.
FIG. 1A is a simplified diagram of the two threads in a SoEMT system 10 operating in a wide processor. In SoEMT system 10, only one thread (indicated by numbers 1 and 2) may be active at a given time. If thread 1 encounters a stalling event such as a cache miss, SoEMT system 10 switches control to thread 2, which was inactive before switching. Thread 2 may have control over the processor until another stalling event occurs or until a certain amount of time has elapsed, upon which the processor may switch back to execute the original thread or execute a different thread.
While the ability to switch the processor between threads increases processor utilization, SoEMT system 10 is not able to take advantage of the additional bandwidth in a wide processor because only one thread may be active at a time. Therefore, even in the most optimal scenario, SoEMT system 10 is like any single threaded machine and able to utilize only half of the wide processor bandwidth. However, SoEMT systems remain very useful because they decrease the number of idle cycles experienced by the processor whenever there is a cache miss.
FIG. 1B is a simplified diagram of a two threaded SMT system 12 operating in a wide processor. In the SMT system, multiple threads are able to issue instructions during each cycle. Unlike SoEMT, where only a single thread is active on a given cycle, SMT permits multiple threads to compete for and share processor resources at the same time. The threads are scheduled concurrently and therefore operations from both threads progress down the pipeline simultaneously. The result is a dramatic increase in system performance, including higher instruction throughput and program acceleration in both multi-programmed and parallel environments.
Unfortunately, the SMT systems have a much larger machine cost and require more machine resources than a SoEMT system. Furthermore, the effectiveness of SMT decreases as the number of threads increases because the underlying machine resources are limited and because of the exponential cost increase of inspecting each additional thread. SMT systems are also vulnerable to being disrupted by the same stalling events that plague single threaded machines. Therefore, when a stalling event occurs in a SMT thread, the processor will experience idle cycles while the long latency operation occurs. As shown in FIG. 1B, if both threads 1 and 2 experience cache misses at the same time, the entire processor will be stalled because there are no other threads to switch in.
In view of the foregoing, it is desirable to have a method and apparatus that provides for a system able to maximize the use of wide processor resources. This may be accomplished by providing a multi-threading system that is able to execute two threads simultaneously and switch processor resources to execute an inactive thread when an active thread encounters a stalling event. It is also desirable to accomplish this goal with minimal circuit impact and minimal additional overhead.